package com.ruoyi.system.service.impl;

import java.util.List;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.system.api.domain.SysUserImel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.SysUserImelMapper;
import com.ruoyi.system.service.ISysUserImelService;

/**
 * 用户设备关系Service业务层处理
 * 
 * @author ruoyi
 * @date 2021-08-11
 */
@Service
public class SysUserImelServiceImpl implements ISysUserImelService 
{
    @Autowired
    private SysUserImelMapper sysUserImelMapper;

    /**
     * 查询用户设备关系
     * 
     * @param id 用户设备关系ID
     * @return 用户设备关系
     */
    @Override
    public SysUserImel selectSysUserImelById(Long id)
    {
        return sysUserImelMapper.selectSysUserImelById(id);
    }

    /**
     * 查询用户设备关系列表
     * 
     * @param sysUserImel 用户设备关系
     * @return 用户设备关系
     */
    @Override
    public List<SysUserImel> selectSysUserImelList(SysUserImel sysUserImel)
    {
        return sysUserImelMapper.selectSysUserImelList(sysUserImel);
    }

    /**
     * 新增用户设备关系
     * 
     * @param sysUserImel 用户设备关系
     * @return 结果
     */
    @Override
    public int insertSysUserImel(SysUserImel sysUserImel)
    {
        List<SysUserImel> doList = sysUserImelMapper.selectSysUserImelList(sysUserImel);
        if(doList.size() > 0){
            return 0;
        }
        sysUserImel.setStatus("1");//默认有效状态
        sysUserImel.setCreateTime(DateUtils.getNowDate());
        return sysUserImelMapper.insertSysUserImel(sysUserImel);
    }

    /**
     * 修改用户设备关系
     * 
     * @param sysUserImel 用户设备关系
     * @return 结果
     */
    @Override
    public int updateSysUserImel(SysUserImel sysUserImel)
    {
        sysUserImel.setUpdateTime(DateUtils.getNowDate());
        return sysUserImelMapper.updateSysUserImel(sysUserImel);
    }

    /**
     * 批量删除用户设备关系
     * 
     * @param ids 需要删除的用户设备关系ID
     * @return 结果
     */
    @Override
    public int deleteSysUserImelByIds(Long[] ids)
    {
        return sysUserImelMapper.deleteSysUserImelByIds(ids);
    }

    /**
     * 删除用户设备关系信息
     * 
     * @param id 用户设备关系ID
     * @return 结果
     */
    @Override
    public int deleteSysUserImelById(Long id)
    {
        return sysUserImelMapper.deleteSysUserImelById(id);
    }
}
